package helper;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableUtils;

public class CompositeKey implements WritableComparable<CompositeKey> {
	int user;
	int similar;
		
	public void write(DataOutput out) throws IOException {
		WritableUtils.writeVInt(out, user);
		WritableUtils.writeVInt(out, similar);
	}
	
	public void readFields(DataInput in) throws IOException {
		this.user = WritableUtils.readVInt(in);
		this.similar = WritableUtils.readVInt(in);
	}
	
	public int compareTo(CompositeKey pop) {
		if (pop == null)
			return 0;
		int intcnt = Integer.compare(this.user, pop.user);
		
		return intcnt;
	}
	
	@Override
	public String toString() {
		return user + "-" + similar;
	}

    public int getUser() {
        return user;
    }

    public void setUser(int user) {
        this.user = user;
    }

    public int getSimilar() {
        return similar;
    }

    public void setSimilar(int similar) {
        this.similar = similar;
    }
	

}
